/*
*  Copyright 2019-2025 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.transfer.rest;

import me.zhengjie.annotation.Log;
import me.zhengjie.modules.transfer.domain.TransferAftt;
import me.zhengjie.modules.transfer.service.TransferAfttService;
import me.zhengjie.modules.transfer.domain.dto.TransferAfttQueryCriteria;
import lombok.RequiredArgsConstructor;

import java.util.HashMap;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;

/**
* @author lzw
* @date 2025-06-13
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "api")
@RequestMapping("/api/transferAftt")
public class TransferAfttController {

    private final TransferAfttService transferAfttService;

    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('transferAftt:list')")
    public void exportTransferAftt(HttpServletResponse response, TransferAfttQueryCriteria criteria) throws IOException {
        transferAfttService.download(transferAfttService.queryAll(criteria), response);
    }

    @GetMapping
    @ApiOperation("查询api")
    @PreAuthorize("@el.check('transferAftt:list')")
    public ResponseEntity<PageResult<TransferAftt>> queryTransferAftt(TransferAfttQueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(transferAfttService.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping
    @Log("新增api")
    @ApiOperation("新增api")
    @PreAuthorize("@el.check('transferAftt:add')")
    public ResponseEntity<Object> createTransferAftt(@Validated @RequestBody TransferAftt resources){
        transferAfttService.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改api")
    @ApiOperation("修改api")
    @PreAuthorize("@el.check('transferAftt:edit')")
    public ResponseEntity<Object> updateTransferAftt(@Validated @RequestBody TransferAftt resources){
        transferAfttService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除api")
    @ApiOperation("删除api")
    @PreAuthorize("@el.check('transferAftt:del')")
    public ResponseEntity<Object> deleteTransferAftt(@ApiParam(value = "传ID数组[]") @RequestBody List<String> ids) {
        transferAfttService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @PostMapping("getaftt")
    public ResponseEntity<Object> getaftt(@RequestBody Map map){

        return new ResponseEntity<>(transferAfttService.getaftt( map),HttpStatus.OK);
    }
}
